package org.cdc.mre.manager;

import com.alibaba.fastjson.JSONObject;

import java.io.*;

public class JSONManager {
    public static JSONObject compileJSONObject(String json){
        return JSONObject.parseObject(json);
    }
    public static JSONObject compileJSONObjectForFile(String fileName) throws IOException {
        String encoding = "UTF-8";
        File file = new File(fileName);
        Long filelength = file.length();
        byte[] filecontent = new byte[filelength.intValue()];
        try {
            FileInputStream in = new FileInputStream(file);
            in.read(filecontent);
            in.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return JSONObject.parseObject(new String(filecontent, encoding));
    }
}
